﻿<Window x:Class="WpfWordsLearner.Views.TestView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:conv="clr-namespace:WpfWordsLearner.Converters"
        xmlns:vm="clr-namespace:WpfWordsLearner.ViewModels"
        Title="Test View"
        Width="400"
        Height="300">
	<Window.Resources>
		<vm:TestViewModel x:Key="TestVM" />
		<conv:BoolToVisibilityConverter x:Key="BoolToVisibility" />
		<conv:ReverseBoolToVisibilityConverter x:Key="ReverseBoolToVisibility" />
	</Window.Resources>
	<Grid Name="MainLayout" DataContext="{Binding Source={StaticResource TestVM}}">
		<Grid.RowDefinitions>
			<RowDefinition Height="35" />
			<RowDefinition />
			<RowDefinition Height="40" />
		</Grid.RowDefinitions>
		<StackPanel Orientation="Horizontal">
			<TextBlock Margin="2,0,0,0"
			           VerticalAlignment="Center"
			           Text="Give answers:" />
			<CheckBox Margin="3,0,0,0"
			          VerticalAlignment="Center"
			          Content="Check if you want to view answers"
			          IsChecked="{Binding Path=UseAnswers,
			                              Mode=TwoWay}" />
		</StackPanel>
		<Grid Grid.Row="1">
			<Grid.RowDefinitions>
				<RowDefinition />
				<RowDefinition />
			</Grid.RowDefinitions>
			<StackPanel Grid.Row="0" DataContext="{Binding Path=Word}">
				<TextBlock Text="Word:" />
				<TextBox x:Name="txtWord" Text="{Binding Source={StaticResource TestVM}, Path=CurrentAnswer.Word.EnglishWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
				<Button Width="35" Height="35" HorizontalAlignment="Left" VerticalAlignment="Bottom" 
						Command="{Binding Source={StaticResource TestVM},Path=VoiceCommand}">
					<Button.Content>
						<Image Source="pack://application:,,,/Images/voice.jpg" />
					</Button.Content>
				</Button>
			</StackPanel>
			<StackPanel Grid.Row="1" Visibility="{Binding UseAnswers, Converter={StaticResource ReverseBoolToVisibility}}">
				<TextBlock Text="Answer:" />
				<TextBox x:Name="txtAnswer" Text="{Binding Path=CurrentAnswer.Answer, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
			</StackPanel>
			<StackPanel Grid.Row="1" Visibility="{Binding UseAnswers, Converter={StaticResource BoolToVisibility}}">
				<ComboBox ItemsSource="{Binding PossibleAnswers}"
				          SelectedIndex="0"
				          SelectedItem="{Binding Path=CurrentAnswer.Answer,
				                                 Mode=TwoWay}" />
			</StackPanel>
		</Grid>
		<StackPanel Grid.Row="2"
		            HorizontalAlignment="Center"
		            DataContext="{Binding Source={StaticResource TestVM}}"
		            Orientation="Horizontal">
			<Button x:Name="btnNext"
			        Width="60"
			        Command="{Binding Path=NextCommand}"
			        Content="Next"
			        IsEnabled="{Binding Path=IsNextAvaliable}" />
			<Button x:Name="btnResult"
			        Width="60"
			        Command="{Binding Path=ResultCommand}"
			        Content="Result"
			        Visibility="{Binding Path=IsResultAvaliable,
			                             Mode=TwoWay,
			                             Converter={StaticResource BoolToVisibility}}" />
		</StackPanel>
	</Grid>
</Window>

